<template>
	<scroll-page background-color="#F6F7F9">
		<view class="my-page">
			<!-- 用户资料（头像&昵称） -->
			<view class="user-profile">
				<image class="user-avatar" src="/static/uploads/doctor-avatar.jpg"></image>
				<view class="user-info">
					<text class="nickname">用户907456</text>
					<text class="iconfont icon-edit"></text>
				</view>
			</view>
			<!-- 用户数据 -->
			<view class="user-data">
				<navigator hover-class="none" url=" ">
					<text class="data-number">150</text>
					<text class="data-label">收藏</text>
				</navigator>
				<navigator hover-class="none" url=" ">
					<text class="data-number">23</text>
					<text class="data-label">关注</text>
				</navigator>
				<navigator hover-class="none" url=" ">
					<text class="data-number">230</text>
					<text class="data-label">积分</text>
				</navigator>
				<navigator hover-class="none" url=" ">
					<text class="data-number">3</text>
					<text class="data-label">优惠券</text>
				</navigator>
			</view>
			<!-- 问诊医生 -->
			<custom-section :custom-style="{ paddingBottom: '20rpx' }" title="问诊中">
				<swiper class="uni-swiper" indicator-active-color="#2CB5A5" indicator-color="#EAF8F6" indicator-dots>
					<swiper-item>
						<view class="doctor-brief">
							<image class="doctor-avatar" src="/static/uploads/doctor-avatar.jpg" />
							<view class="doctor-info">
								<view class="meta">
									<text class="name">王医生</text>
									<text class="title">内分泌科 | 主任医师</text>
								</view>
								<view class="meta">
									<text class="tag">三甲</text>
									<text class="hospital">积水潭医院</text>
								</view>
							</view>
							<navigator class="doctor-contcat" hover-class="none" url=" ">进入咨询</navigator>
						</view>
					</swiper-item>
					<swiper-item>
						<view class="doctor-brief">
							<image class="doctor-avatar" src="/static/uploads/doctor-avatar.jpg" />
							<view class="doctor-info">
								<view class="meta">
									<text class="name">王医生</text>
									<text class="title">内分泌科 | 主任医师</text>
								</view>
								<view class="meta">
									<text class="tag">三甲</text>
									<text class="hospital">积水潭医院</text>
								</view>
							</view>
							<navigator class="doctor-contcat" hover-class="none" url=" ">进入咨询</navigator>
						</view>
					</swiper-item>
				</swiper>
			</custom-section>
			<!-- 药品订单 -->
			<custom-section show-arrow title="药品订单">
				<template #right>
					<navigator hover-class="none" url=" ">全部订单</navigator>
				</template>
				<view class="drug-order">
					<navigator hover-class="none" url=" ">
						<uni-badge :text="0" :offset="[3, 3]" absolute="rightTop">
							<image src="/static/images/order-status-1.png" class="status-icon" />
						</uni-badge>
						<text class="status-label">待付款</text>
					</navigator>
					<navigator hover-class="none" url=" ">
						<uni-badge text="2" :offset="[3, 3]" absolute="rightTop">
							<image src="/static/images/order-status-2.png" class="status-icon" />
						</uni-badge>
						<text class="status-label">待付款</text>
					</navigator>
					<navigator hover-class="none" url=" ">
						<uni-badge :text="0" :offset="[3, 3]" absolute="rightTop">
							<image src="/static/images/order-status-3.png" class="status-icon" />
						</uni-badge>
						<text class="status-label">待付款</text>
					</navigator>
					<navigator hover-class="none" url=" ">
						<uni-badge :text="0" :offset="[3, 3]" absolute="rightTop">
							<image src="/static/images/order-status-4.png" class="status-icon" />
						</uni-badge>
						<text class="status-label">待付款</text>
					</navigator>
				</view>
			</custom-section>
			<!-- 快捷工具 -->
			<custom-section title="快捷工具">
				<uni-list :border="false">
					<uni-list-item
						:border="false"
						title="我的问诊"
						show-arrow
						show-extra-icon
						:extra-icon="{
							customPrefix: 'icon-symbol',
							type: 'icon-symbol-tool-01'
						}"
					/>
					<uni-list-item
						:border="false"
						title="我的处方"
						show-arrow
						show-extra-icon
						:extra-icon="{
							customPrefix: 'icon-symbol',
							type: 'icon-symbol-tool-02'
						}"
					/>
					<uni-list-item
						:border="false"
						title="家庭档案"
						show-arrow
						to="/subpack/list/list"
						show-extra-icon
						:extra-icon="{
							customPrefix: 'icon-symbol',
							type: 'icon-symbol-tool-03'
						}"
					/>
					<uni-list-item
						:border="false"
						title="地址管理"
						show-arrow
						show-extra-icon
						:extra-icon="{
							customPrefix: 'icon-symbol',
							type: 'icon-symbol-tool-04'
						}"
					/>
					<uni-list-item
						:border="false"
						title="我的评价"
						show-arrow
						show-extra-icon
						:extra-icon="{
							customPrefix: 'icon-symbol',
							type: 'icon-symbol-tool-05'
						}"
					/>
					<uni-list-item
						:border="false"
						title="官方客服"
						show-arrow
						show-extra-icon
						:extra-icon="{
							customPrefix: 'icon-symbol',
							type: 'icon-symbol-tool-06'
						}"
					/>
					<uni-list-item
						:border="false"
						title="设置"
						show-arrow
						show-extra-icon
						:extra-icon="{
							customPrefix: 'icon-symbol',
							type: 'icon-symbol-tool-07'
						}"
					/>
				</uni-list>
			</custom-section>
			<!-- 退出登录 -->
			<view class="logout-button" @click="onLogoutClick">退出登录</view>
		</view>
	</scroll-page>
</template>

<script setup>
import useMyUserStore from '@/store/my.js';
import useLoginStore from '@/store/login.js';

const myUserStore = useMyUserStore();
const loginStore = useLoginStore();

myUserStore.patientMyUserApiAction();

// 退出登录
const onLogoutClick = () => {
	// 清空token
	loginStore.token = '';

	loginStore.recirectURL = '/pages/index/index';
	loginStore.openType = 'switchTab';

	uni.reLaunch({
		url: '/pages/login/login'
	});
};
</script>

<style lang="scss">
// pages/my/index.scss
.my-page {
	min-height: 500rpx;
	padding: 50rpx 30rpx 10rpx;
	background-image: linear-gradient(180deg, rgba(44, 181, 165, 0.46) 0, rgba(44, 181, 165, 0) 500rpx);
}

.user-profile {
	display: flex;
	align-items: center;
	height: 140rpx;
}

.user-avatar {
	width: 140rpx;
	height: 140rpx;
	border-radius: 50%;
}

.user-info {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	line-height: 1;
	padding: 30rpx 0;
	margin-left: 24rpx;

	.nickname {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.icon-edit {
		color: #16c2a3;
		padding-top: 20rpx;
		font-size: 32rpx;
	}
}

.user-data {
	display: flex;
	justify-content: space-around;

	height: 100rpx;
	text-align: center;
	line-height: 1;
	margin: 50rpx 0 30rpx;

	.data-number {
		display: block;
		margin-bottom: 10rpx;
		font-size: 36rpx;
		color: #333;
	}

	.data-label {
		display: block;
		font-size: 24rpx;
		color: #979797;
	}
}

.doctor-brief {
	display: flex;
	align-items: center;
	height: 160rpx;

	.doctor-avatar {
		width: 100rpx;
		height: 100rpx;
		margin-left: 10rpx;
		border-radius: 50%;
	}

	.doctor-info {
		height: 100rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin-left: 12rpx;
		flex: 1;
	}

	.name {
		font-size: 36rpx;
		color: #3c3e42;
		margin-right: 10rpx;
	}

	.title {
		font-size: 24rpx;
		color: #6f6f6f;
	}

	.tag {
		line-height: 1;
		padding: 2rpx 16rpx;
		font-size: 22rpx;
		color: #fff;
		border-radius: 6rpx;
		background-color: #677fff;
	}

	.hospital {
		font-size: 26rpx;
		color: #3c3e42;
		margin-left: 10rpx;
	}

	.doctor-contcat {
		line-height: 1;
		padding: 16rpx 24rpx;
		border-radius: 100rpx;
		font-size: 24rpx;
		color: #2cb5a5;
		background-color: rgba(44, 181, 165, 0.1);
	}
}

.uni-swiper {
	height: 200rpx;
}

.drug-order {
	display: flex;
	justify-content: space-between;
	text-align: center;
	padding: 30rpx 20rpx 10rpx;

	.status-icon {
		width: 54rpx;
		height: 54rpx;
	}

	.status-label {
		display: block;
		font-size: 24rpx;
		margin-top: 10rpx;
		color: #3c3e42;
	}
}

:deep(.uni-list-item__content-title) {
	font-size: 30rpx !important;
	color: #3c3e42 !important;
}

:deep(.uni-list-item__container) {
	padding: 20rpx 0 !important;
}

:deep(.uni-icon-wrapper) {
	padding-right: 0 !important;
	color: #c3c3c5 !important;
}

:deep(.uni-icons) {
	display: block !important;
}

.logout-button {
	height: 88rpx;
	text-align: center;
	line-height: 88rpx;
	margin: 40rpx 0 30rpx;
	border-radius: 20rpx;
	font-size: 32rpx;
	color: #3c3e42;
	background-color: #fff;
}
</style>
